package com.leyou.item.client;



import com.leyou.common.dto.PageDTO;
import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@FeignClient("item-service")
public interface ItemClient {


    @GetMapping("/goods/spu/page")
    PageDTO<SpuDTO> spuPageQuery(
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "rows", defaultValue = "5") Integer rows,
            @RequestParam(value = "categoryId", required = false) Long cid,
            @RequestParam(value = "brandId", required = false) Long bid,
            @RequestParam(value = "saleable", required = false) Boolean saleable,
            @RequestParam(value = "id", required = false) Long id);


    @GetMapping("/brand/{id}")
    BrandDTO queryBrandById(@PathVariable("id") Long id);


    @GetMapping("/category/{id}")
    CategoryDTO queryCategoryById(@PathVariable("id") Long id);


    @GetMapping("/goods/sku/of/spu")
    List<SkuDTO> listSkuBySpu(@RequestParam("id") Long id);


    @GetMapping("/goods/spec/value")
    List<SpecParamDTO> querySpecParamValue(
            @RequestParam("id") Long id,
            @RequestParam(value = "searching", required = false) Boolean searching);

    @GetMapping("/brand/list")
    List<BrandDTO> listBrandByIds(@RequestParam("ids") List<Long> ids);


    @GetMapping("/category/list")
    List<CategoryDTO> listCategoryByIds(@RequestParam("ids") List<Long> ids);


    @GetMapping("/goods/spu/{id}")
    SpuDTO querySpuById(@PathVariable("id") Long id);


    @GetMapping("/goods/spu/detail")
    SpuDetailDTO querySpuDetailById(@RequestParam("id") Long spuId);


    @GetMapping("/spec/list")
    List<SpecGroupDTO> querySpecByCategory(@RequestParam("id") Long cid);


    @GetMapping("/goods/sku/list")
    List<SkuDTO> listSkuByIds(@RequestParam("ids") List<Long> ids);


    @GetMapping("/goods/sku/minus/stock")
    Void minusStock(@RequestBody Map<Long, Integer> cartsMap);


}
